#include <iostream>
#include <vector>

using namespace std;

class Solution {
private:
    vector<string> ans;
    void dfs(int index, string& num, char operate, int64_t num1, int64_t num2, int64_t target, string& his) {
        if (operate != ' ') {
            his.push_back(operate);
        }
        for (int i = index; i < num.size(); i++) {
            int64_t _num1 = num1;
            int64_t _num2 = num2;
            string val_str = num.substr(index, i - index + 1);
            his.append(val_str);
            int64_t val = strtol(val_str.data(), NULL, 10 );
            if (operate == '+') {
                _num1 += _num2;
                _num2 = val;
            } else if (operate == '-') {
                _num1 += _num2;
                _num2 = -val;
            } else if (operate == '*') {
                _num2 *= val;
            } else if (operate == ' ') {
                _num2 = val;
            }
            if (i + 1 == num.size()) {
                if (_num1 + _num2 == target) {
                    ans.push_back(his);
                }
                goto next;
            }
            dfs(i + 1, num, '+', _num1, _num2, target, his);
            dfs(i + 1, num, '-', _num1, _num2, target, his);
            dfs(i + 1, num, '*', _num1, _num2, target, his);
            next:
            for (int i = 0; i < val_str.size(); i++) {
                his.pop_back();
            }
            if (val == 0) {
                break;
            }
        }
        if (operate != ' ') {
            his.pop_back();
        }
    }
public:
    vector<string> addOperators(string num, int target) {
        if (num.size() == 0) {
            return {};
        } else if (num.size() == 1) {
            return {};
        }
        string his = "";
        dfs(0, num, ' ', 0, 0, target, his);
        return ans;
    }
};

int main() {
    Solution solution;
    vector<string> output = solution.addOperators("2147483648", -2147483648);
    for (string item : output) {
        cout << item << endl;
    }
    return 0;
}
